﻿/**
 * ...
 * @author alijaya
 */

package homponex.core;

class Container extends Component
{

	private var defaultPanel:Panel;
	private var panels:Hash<Panel>;
	
	private function new() 
	{
		super();
		panels = new Hash<Panel>;
	}
	
	public function getPanel(?id:String) : Panel
	{
		var p:Panel;
		if (id != null)
		{
			p = panels.get(id);
			if (p == null) throw "Doesn't contain panel's id " + id;
		} else
		{
			p = defaultPanel;
		}
		return p;
	}
	
	private function addPanel(panel:Panel, id:String) : Void
	{
		panels.set(id, panel);
	}
	
	private function removePanel(id:String) : Void
	{
		panels.remove(id);
	}
}